<template>
  <div>
    <Breadcrumb>
      <BreadcrumbItem href="../ViewOrders">订单查询</BreadcrumbItem>
      <BreadcrumbItem>订单详情</BreadcrumbItem>
    </Breadcrumb>
    <div style="margin-top: 30px;">
      <Form :label-width="100" :model="orderForm" style="width: 80%;">
        <Form-item label="商户订单号" prop="orderNo">
          <Input v-model="orderForm.orderNo"/>
        </Form-item>
        <Form-item label="订单标题" prop="subject">
          <Input v-model="orderForm.subject"/>
        </Form-item>
        <Form-item label="订单描述" type="textarea" prop="body">
          <Input v-model="orderForm.body"/>
        </Form-item>
        <Form-item label="金额(元)" prop="amount">
          <Input v-model="orderForm.amount"/>
        </Form-item>
        <Form-item label="交易渠道名称" prop="channelName">
          <Input v-model="orderForm.channelName"/>
        </Form-item>
        <Form-item label="创建时间" prop="createTime">
          <Input v-model="orderForm.createTime"/>
        </Form-item>
        <Form-item label="交易状态" prop="status">
          <Input v-model="orderForm.status"/>
        </Form-item>
      </Form>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
  import Model from '@/models/apps'
  import time from '@/utils/helpers/timeLite'
  export default {
    name: 'orderDetail',
    data () {
      return {
        orderForm: {
          subject: '',
          body: '',
          orderNo: '',
          amount: '',
          channelName: '',
          createTime: '',
          status: ''
        }
      }
    },
    created () {
      this.get()
    },
    methods: {
      get () {
        new Model('order')
          .GET({
            params: {
              id: this.$route.params.orderId
            }
          })
          .then((res) => {
            var data = res.data.data
            this.orderForm.subject = data.subject
            this.orderForm.body = data.body
            this.orderForm.orderNo = data.orderNo
            this.orderForm.amount = data.amount
            this.orderForm.channelName = data.channelName
            this.orderForm.createTime = time.getDateTime(data.createTime)

            var arr = new Array(0)
            arr['SUCCESS'] = '交易成功'
            arr['FAILED'] = '交易失败'
            arr['CLOSED'] = '交易关闭'
            arr['CREATED'] = '订单已创建'
            arr['CANCELED'] = '订单已撤销'
            arr['WAITING_PAYMENT'] = '等待支付'
            this.orderForm.status = arr[data.status]
          })
      }
    }
  }
</script>

<style>
</style>
